;+
;PURPOSE
;	to draw from an IMF
;SYNTAX
;	imf_draw, N, pdf=pdf, cumu_pdf=cumu_pdf, alpha=alpha, 
;		min=min1, max=max1
;INPUTS
;	N: number of objects to pull from IMF
;	alpha: the exponent of your power law IMF
;	min: the minimum mass you want to draw out
;	max: the maximum mass you want to draw out
;OUPUTS
;	pdf: the resulting Probability density 
;	cumu_pdf: the cumulative pdf
;NOTES
;       currently only works with salpeter IMF
;	uses method of transformation
;Written by R. da Silva, UCSC, 1-26-10
;-

pro imf_draw, N, pdf=pdf,  alpha=alpha, min=min1, max=max1
alphapp=alpha+1.
rand1=randomu(seed, N)
y1=max1
y0=min1
pdf=(rand1*y1^alphapp+(1.-rand1)*y0^alphapp)^(1./alphapp)
;cumu_pdf=total(pdf, /cumul)
end

